package com.meida.module.bus.provider.handler;

import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.PageInterceptor;
import com.meida.common.mybatis.model.PageParams;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.user.client.entity.AppUser;
import com.meida.module.user.client.entity.AppWorkhistory;
import org.springframework.stereotype.Component;

/**
 * 后台用户工作经历列表
 */
@Component
public class AppWorkhistoryPageListHandler implements PageInterceptor<AppWorkhistory> {


    @Override
    public void prepare(CriteriaQuery<AppWorkhistory> cq, PageParams pageParams, EntityMap params) {
        cq.clear();
        String beginDate = params.get("beginDate");
        String endDate = params.get("endDate");
        cq.select(AppWorkhistory.class, "workhistoryId", "parentId", "companyName", "positionName", "state", "companyAddress", "workingDate", "createTime");
        cq.select(AppUser.class, "userName");
        cq.eq(AppWorkhistory.class, "state");
        cq.eq(AppWorkhistory.class, "userId");
        cq.like(AppUser.class, "userName");
        cq.ge("DATE_FORMAT(workhistory.createTime,'%Y-%m-%d')", beginDate);
        cq.le("DATE_FORMAT(workhistory.createTime,'%Y-%m-%d')", endDate);
        cq.createJoin(AppUser.class).setMainField("userId").setJoinField("userId");
    }


}
